<template>
  <div>
    <van-nav-bar
      :title="comment.reply_count ? comment.reply_count + '条回复' : '暂无回复'"
      @click-left="$emit('close')"
    >
      <template #left>
        <van-icon name="cross" />
      </template>
    </van-nav-bar>

<div class="scroll-box">
      <CommentItem :comment="comment" />
     <van-cell title="全部回复" />
     <comment-list type='c' :source="comment.com_id + ''" :list='list' />
</div>

     <div class="post-warp">
      <van-button @click="showReplyPostComment=true" round>评论</van-button>

      <van-popup v-model="showReplyPostComment" position="bottom">
        <comment-post @on-success='onSuccss' :target="comment.com_id + ''" :artId="$route.params.artId" />
      </van-popup>
    </div>
  </div>
</template>

<script>
import CommentItem from './CommentItem.vue'
import CommentList from './CommentList.vue'
import CommentPost from './CommentPost.vue'
export default {
  props: {
    comment: {
      type: Object,
      required: true
    }
  },
  components: { CommentItem, CommentList, CommentPost },
  data () {
    return {
      list: [],
      showReplyPostComment: false
    }
  },

  created () {},

  methods: {
    onSuccss (e) {
      this.list.unshift(e)
      this.showReplyPostComment = false
      this.comment.reply_count++
    }
  }
}
</script>

<style scoped lang="less">
.post-warp {
  width: 100%;
  height: 100px;
  position: fixed;
  bottom: 0;
  border-top: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: hotpink;
  .van-button {
    width: 640px;
    height: 80px;
  }
}
.scroll-box{
  position: absolute;
  width: 100%;
  top: 92px;
  bottom: 100px;
  overflow-y: scroll;
}
</style>
